/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年5月23日
 */
package com.massyframework.beanskin.service.metadata;

import java.util.List;
import java.util.function.Predicate;

/**
 * {@link MetadataRepository}, 元数据仓储
 */
public interface MetadataRepository {
	
	/**
	 * 按类名获取类型元数据
	 * @param className {@link String}
	 * @return {@link ClassMetadata},可能返回null.
	 */
	ClassMetadata findClassMetadata(String className);

    /**
     * 满足{@code filter}的首个类元数据
     * @param filter {@link Predicate}, 过滤条件
     * @return {@link ClassMetadata},可能返回null.
     */
    ClassMetadata findClassMetadata(Predicate<ClassMetadata> filter);

    /**
     * 按类获取对应的类元数据
     * @param clazz 类
     * @return {@link ClassMetadata}
     */
    ClassMetadata getClassMetadata(Class<?> clazz);
    
    /**
     * 按{@code classNameDigest}获取对应的类元数据
     * @param digest {@link String}, 模块名称和类名混合后的MD5摘要
     * @return {@link ClassMetadata}
     * @throws ClassNameDigestNotFoundException 未找到对应的类摘要时抛出的例外
     */
    ClassMetadata getClassMetadataWithDigest(String digest) throws ClassNameDigestNotFoundException;

    /**
     * 所有满足{@code filter}的类元数据
     * @param filter {@link Predicate},过滤器
     * @return {@link ClassMetadata}列表
     */
    List<ClassMetadata> getClassMetadatas(Predicate<ClassMetadata> filter);

    /**
     * 按类型获取含派生关系(父类)的类元数据
     * @param clazz 类型
     * @return
     * 		{@link List}，不能返回null.
     */
    List<ClassMetadata> getHierarchyClassMetadatas(Class<?> clazz);
    
  
    /**
     * 按{@code classNameDigest}和{@code superiorType}确定需要的含派生关系的类元数据
     * @param digest {@link String}, 模块名称和类名混合后的MD5摘要
     * @return {@link List}
     * @throws ClassMetadataNotFoundException 类元数据没找到时抛出的例外
     */
    List<ClassMetadata> getHierarchyClassMetadatasWithDigest(String digest) throws ClassMetadataNotFoundException;
}

